#include "lan2calgridword.h"
#include "lan2calmmp.h"

#include <QGraphicsDropShadowEffect>
#include <QPainter>
LAN2STA
Lan2CalMmp::Lan2CalMmp(int width, int height, QWidget *parent) : QWidget(parent)
{
    this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint| Qt::SubWindow );
//    this->setAttribute(Qt::WA_StyledBackground,true);
    this->setAttribute(Qt::WA_TranslucentBackground,true);
    this->setStyleSheet("QWidget{background:#f3f3f3}");
    this->setFixedSize(width,height);

    QGraphicsDropShadowEffect* shadow=new QGraphicsDropShadowEffect(this);
    shadow->setOffset(0,0);
    shadow->setColor(Qt::black);
    shadow->setBlurRadius(5);
    this->setGraphicsEffect(shadow);


    mgrid=new QGridLayout(this);
//    mgrid->setContentsMargins(24,24,24,24);
    this->setLayout(mgrid);
//    vbox->addLayout(mgrid);
    QList<Lan2CalGridWord*> list_Gridwords;
    list_Gridwords.clear();
    qDeleteAll(list_Gridwords);
    for(int i=0;i<60;i++)
    {
        list_Gridwords.append(new Lan2CalGridWord(QString("%1").arg(i,2,10,QLatin1Char('0')),20,this));
        connect(list_Gridwords.at(i),SIGNAL(sign_click(QString)),this,SLOT(slot_click(QString)));
    }




    int i=0;
    for(int r=0;r<6;r++){
        for(int c=0;c<10;c++){
            if(i<60){
                mgrid->addWidget(list_Gridwords.at(i),r,c);

            }
            i++;

        }
    }

}

void Lan2CalMmp::slot_click(const QString & s)
{
    this->setHidden(true);
    emit sign_sendword(s);
}

void Lan2CalMmp::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.fillRect(this->rect().adjusted(5,5,-5,-5),QColor("#ffffff"));
}

LAN2END
